package com.easylinkin.linkappapi.reportCenter.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.easylinkin.linkappapi.reportCenter.entity.ReportAiDetail;
import com.easylinkin.linkappapi.reportCenter.entity.ReportElectrical;
import com.easylinkin.linkappapi.reportCenter.entity.dto.ReportDetailDTO;
import com.easylinkin.linkappapi.reportCenter.mapper.ReportElectricalMapper;
import com.easylinkin.linkappapi.reportCenter.service.ReportBaseService;
import com.easylinkin.linkappapi.reportCenter.service.ReportElectricalService;
import com.easylinkin.linkappapi.reportCenter.timer.DeviceReportTimer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @Description 电气火灾
 * @Author kan yuanfeng
 * @Date 2023/7/17 14:34
 */
@Service
public class ReportElectricalServiceImpl extends ReportBaseServiceImpl<ReportElectrical> implements ReportElectricalService {
    @Autowired
    private ReportElectricalMapper reportElectricalMapper;
    @Autowired
    private DeviceReportTimer deviceReportTimer;
    @Override
    protected List<ReportElectrical> getByReportId(Integer reportId,Integer type) {
        QueryWrapper<ReportElectrical> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("report_id_",reportId);
        List<ReportElectrical> electricals = reportElectricalMapper.selectList(queryWrapper);
        return electricals;
    }

    @Override
    protected List<ReportElectrical> getLastByDate(String tenantId,Date date,Integer type) {
        //根据时间求上月数据
        List<ReportElectrical> electricalList = deviceReportTimer.countElectrical(tenantId, date, null);
        return electricalList;
    }

    /**
     * 当月数据处理
     * @param reportId
     * @param name
     * @param type (两个数据在一张表时才有)
     * @return
     */
    @Override
    public ReportDetailDTO dataHandler(Integer reportId, String name, Integer type) {
        ReportDetailDTO reportDetailDTO = this.dataHandler(reportId, name, type,null);
        return reportDetailDTO;
    }
}
